<?php


/**
 * @author Admin
 *
 *
 */
class AdminGalleryView extends GalleryView {



	/**
	 *
	 * @see GalleryView::render()
	 */
	public  function render( $config = NULL ) {
		    $cur = $this->_controller->uri->segment(6, 0);
			$renderer = new MultipleImageGallery();
			foreach ( $this->query as $dat ){
				$img =new Image($dat->location, (int)$config["maxwidth"],$dat->width,$dat->height);
				$img->finalize();
				$wrapper = new EditableImageWrapper($dat->title);
				$wrapper->addChild($img);
				$wrapper->title = $dat->title;
				$wrapper->preview = $dat->location;
				$wrapper->id = "img$dat->id";
				$wrapper->editpath = site_url($config["editpath"].$dat->id."/".$config["category_id"]."/".$cur);
				$wrapper->finalize();
				$renderer->addChild($wrapper);
				$renderer->addJSInit(""); 
			}
			
			$config['base_url'] = site_url("admin/images/catId/".$config["category_id"]."/page");
			$config['enable_query_strings'] = TRUE;
			$config['total_rows'] = $this->_controller->gmodel->countImagesInCategory( $config["category_id"] );
			$config['cur_page'] = $cur;
			$config['per_page'] = $config["img_per_page"]; 
			$this->_controller->pagination->initialize($config); 
			$renderer->pagination = $this->_controller->pagination->create_links();
			$renderer->finalize();
			$this->display->addJSInit("
			$(function() {
			$('div.framesection img').verticalAlign();
			});
			");
			$this->display->addChild($renderer,'gallery_item_template');
	}
}


?>